function collaborativePoliceAdd(data) {
  // 画圆
  DrawRound(data);
  // 获取人员信息
  userlistadd(data);
  // 获取协同人员信息
  xtry(data);
	collaborativecardata(vm.Earlywarning)
}

setInterval(function () {
  if (vm.Basisindex == 1) {
    vm.resourcesList = [];
		if(vm.collaborativePoliceState){
			xtry(vm.Earlywarning);
		}
		if(vm.collaborativecarState){
			collaborativecardata(vm.Earlywarning)
		}    		
  }
}, 10000)

function xtry(data) {
  // 获取协同人员信息
  $.ajax({
    type: 'get',
    url: httpurl + 'event/manager/event/getCorrelationPerson/' + data.eId,
    data: {},
    dataType: 'json',
    contentType: "application/json",
    headers: {
      Authorization: localStorage.getItem('token')
    },
    success: function (data) {
      // console.log(data)
      vm.clear('Collaborative-personnel'); // 协同人员
      if (data.code == 200 && data.data.length != 0) {
        for (let [key, val] of Object.entries(data.data)) {
          var point = new BMap.Point(val.lng, val.lat)
          // 创建人员图标
          var myIcon = new BMap.Icon("./Package/images/tb/ry.png", new BMap.Size(34, 34));
          // 点位
          var marker = new BMap.Marker(point, { icon: myIcon });
          // 覆盖物标识
          marker.init = 'Collaborative-personnel'

          var content = `
            <div class="MonitoringSty monbacking">
              <div class="MonitoringSty-title">人员信息</div>
              <div class="MonitoringSty-video">
                <ul class="textShow">
                  <li>
                    <p>姓名</p>:
                    <p>${val.person.name ? val.person.name : ''}</p>
                  </li>
                  <li>
                    <p>职位</p>:
                    <p>${val.person.position ? val.person.position : ''}</p>
                  </li>
                  <li>
                    <p>电话</p>:
                    <p>${val.person.phone ? val.person.phone : ''}</p>
                  </li>
                </ul>
              </div >
              
            </div >
          `
          // <div class ="userTaskAssigned" onclick="Assignedadd(${val.person.id})">
          //   指派任务
          // </div>

          addClickHandler(content, marker, 'Collaborative-personnel') // 监控信息窗口

          // 标签创建
          var name = `
                <div style='width: auto; height: 22px; padding: 2px 5px; line-height: 22px; text-align: center;'>
                  ${val.person.name}-${val.distance}KM
                </div>
              `
          var Distance = val.person.name.length * 8
          var opts = {
            position: point,    // 指定文本标注所在的地理位置
            offset: new BMap.Size(-Distance, 20)    //设置文本偏移量
          }
          let label = new BMap.Label(name, opts);  // 创建文本标注对象
          label.init = "Collaborative-personnel"
          label.setStyle({
            color: "#000",       //文本颜色
            fontSize: "14px",
            lineHeight: "24px",
            fontFamily: "微软雅黑",
            border: "0",
            borderRadius: '4px'
          });

          // 判断是否有经纬度
          if (val.lng) {
            vm.resourcesList.push({
              name: val.person.name,
              api_distance_km: val.distance,
              lng: val.lng,
              lat: val.lat,
              img: './Package/images/tb/ry.png',
              init: 'Collaborative-personnel'
            })

            vm.map.addOverlay(label);
            vm.map.addOverlay(marker);
          }
        }
				// 排序
				vm.resourcesList = vm.resourcesList.sort(compare('api_distance_km'))
      }
    },
    error: function (err) {
      // 失败的回调
      console.log(err)
    }
  })
}

function collaborativecardata(data) {
  // 获取协同人员信息
  $.ajax({
    type: 'get',
    url: httpurl + 'event/app/getCorrelationCar/' + data.eId,
    data: {},
    dataType: 'json',
    contentType: "application/json",
    headers: {
      Authorization: localStorage.getItem('token')
    },
    success: function (data) {
      // console.log(data)
      vm.clear('Collaborative-car'); // 协同人员
      if (data.code == 200 && data.data.length != 0) {
        for (let [key, val] of Object.entries(data.data)) {
          var point = new BMap.Point(val.lng, val.lat)
          var myIcon = new BMap.Icon("./Package/images/tb/caricon.png", new BMap.Size(34, 34));
          // 点位
          var marker = new BMap.Marker(point, { icon: myIcon });
          // 覆盖物标识
          marker.init = 'Collaborative-car'

          var content = `
            <div class="MonitoringSty monbacking">
              <div class="MonitoringSty-title">车辆信息</div>
              <div class="MonitoringSty-video">
                <ul class="textShow">
                  <li>
                  	<p>车牌号</p>:
                  	<p>${val.vehiIdno ? val.vehiIdno : ''}</p>
                  </li>
                  <li>
                  	<p>位置</p>:
                  	<p>${val.pos ? val.pos : ''}</p>
                  </li>
                </ul>
              </div >
              
            </div >
          `
          // <div class ="userTaskAssigned" onclick="Assignedadd(${val.person.id})">
          //   指派任务
          // </div>

          addClickHandler(content, marker, 'Collaborative-car') // 监控信息窗口

          // 标签创建
          var name = `
                <div style='width: auto; height: 22px; padding: 2px 5px; line-height: 22px; text-align: center;'>
                  ${val['vehiIdno']}-${val.distance}KM
                </div>
              `
          var Distance = val['vehiIdno'].length * 8
          var opts = {
            position: point,    // 指定文本标注所在的地理位置
            offset: new BMap.Size(-Distance, 20)    //设置文本偏移量
          }
          let label = new BMap.Label(name, opts);  // 创建文本标注对象
          label.init = "Collaborative-car"
          label.setStyle({
            color: "#000",       //文本颜色
            fontSize: "14px",
            lineHeight: "24px",
            fontFamily: "微软雅黑",
            border: "0",
            borderRadius: '4px'
          });

          // 判断是否有经纬度
          if (val.lng) {
            vm.resourcesList.push({
              name: val.vehiIdno,
              api_distance_km: val.distance,
              lng: val.lng,
              lat: val.lat,
              img: './Package/images/tb/caricon.png',
              init: 'Collaborative-car'
            })

            vm.map.addOverlay(label);
            vm.map.addOverlay(marker);
          }
        }
				// 排序
				vm.resourcesList = vm.resourcesList.sort(compare('api_distance_km'))
      }
    },
    error: function (err) {
      // 失败的回调
      console.log(err)
    }
  })
}